package zjs.dc.controller;

import org.apache.spark.sql.SparkSession;

/**
 * @Class:
 * @Author: kongcb
 * @Description: t_business_risk_count
 * @Date: 2021/12/28 18:23
 */
public class TBusinessRiskCount {
    public static void main(String[] args) {
        SparkSession spark = SparkSession.builder().appName("t_business_risk_count").enableHiveSupport().getOrCreate();
        spark.sparkContext().setLogLevel("ERROR");
        //企业工商数据t_eci_company
        spark.sql("select company_id,company_name from a_dc_ep_ods.t_eci_company").createOrReplaceTempView("eci_company");
        //企业工商数据t_eci_partner
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_operateexception group by company_id").createOrReplaceTempView("eci_operateexception");
        //企业工商数据t_eci_employee
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_seriousviolation group by company_id").createOrReplaceTempView("eci_seriousviolation");
        //企业工商数据t_eci_branch
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_pledge group by company_id").createOrReplaceTempView("eci_pledge");
        //企业工商数据t_eci_change
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_penalty group by company_id").createOrReplaceTempView("eci_penalty");
        //企业工商数据t_investinfo
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_movablespledge group by company_id").createOrReplaceTempView("eci_movablespledge");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_liquidation group by company_id").createOrReplaceTempView("eci_liquidation");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_simplecancellation group by company_id").createOrReplaceTempView("eci_simplecancellation");
        //企业工商数据t_annual_report--
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_tax_illegal_detail group by company_id").createOrReplaceTempView("tax_illegal_detail");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_land_mortgage_details group by company_id").createOrReplaceTempView("land_mortgage_details");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_publish_notice_detail group by company_id").createOrReplaceTempView("publish_notice_detail");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_env_punishment group by company_id").createOrReplaceTempView("env_punishment");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_auction group by company_id").createOrReplaceTempView("auction");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_tax_owe group by company_id").createOrReplaceTempView("tax_owe");

        spark.sql("insert overwrite table a_dc_ep_incr.t_manage_count select a.company_id,a.company_name,c.cn,d.cn,e.cn,f.cn,g.cn,h.cn,i.cn,j.cn,k.cn,l.cn,m.cn,n.cn,o.cn from eci_company a " +
                "left join eci_operateexception c on a.company_id = c.company_id " +
                "left join eci_seriousviolation d on a.company_id = d.company_id " +
                "left join eci_pledge e on a.company_id = e.company_id " +
                "left join eci_penalty f on a.company_id = f.company_id " +
                "left join eci_movablespledge g on a.company_id = g.company_id " +
                "left join eci_liquidation h on a.company_id = h.company_id " +
                "left join eci_simplecancellation i on a.company_id = i.company_id " +
                "left join tax_illegal_detail j on a.company_id = j.company_id " +
                "left join land_mortgage_details k on a.company_id = k.company_id " +
                "left join publish_notice_detail l on a.company_id = l.company_id " +
                "left join env_punishment m on a.company_id = m.company_id " +
                "left join auction n on a.company_id = n.company_id " +
                "left join tax_owe o on a.company_id = o.company_id ");
        spark.stop();
    }
}
